package com.dorado.example.controller;

import com.dorado.kernel.common.utils.JSONUtils;
import com.dorado.kernel.core.exchange.ResponseEntity;
import com.dorado.kernel.core.exchange.StatusCode;
import com.dorado.kernel.core.service.IRedisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.List;

@CrossOrigin(origins = "*", maxAge = 3600)
@Slf4j
@RestController
@RequestMapping("/test")
//@RefreshScope
public class TestController /*extends BaseController*/ {

    //@Autowired
    //private IOrderMqService orderMqService;

    //@Autowired
    //private ExcelService excelService;

    @Autowired
    private IRedisService redisService;
    //@Autowired
    //private RedisTemplate redisTemplate;

    //@Value("${ssl.user}")
    private String url;

    //@Autowired
    //private ICompanyService companyService;

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    //@MongoDataSourceSwitch(value = "config")
    public ResponseEntity list() {
        CompVO accessLog = new  CompVO();
        //companyService.insert(accessLog);
        accessLog.setPhone("13818429109");
        log.info("{}", accessLog);
        return StatusCode.OK.build();
    }

    @RequestMapping(value = "/redis", method = RequestMethod.GET)
    public ResponseEntity setReids() {
        List<String> list = new ArrayList<>();
        list.add("eeeee");
        list.add("5555");
        //redisService.set("key-44", list);
       // redisService.set("key-33", 3333d);
        //String ss = redisService.get("key-33");
        redisService.set("key-11", "3333");
        String s11 = redisService.get("key-11");
       // DynamicRedisContextHolder.setRedisSource("L1");
        redisService.set("key-22", JSONUtils.toJSONString(StatusCode.OK.build(3333)));
        String s1 = redisService.get("key-22");
        return StatusCode.OK.build(s1);
    }

    //@ExportFile(title = "阿京网集团报表统计【动态title】", fileName = "财务数据-采购到货.xlsx", sheetName = "采购到货", destination = Destination.HTTP, taskType = TaskType.NORMAL)
    @RequestMapping(value = "/exportFile", method = RequestMethod.GET)
    public ResponseEntity exportFile() throws Exception {
        ResponseEntity responseEntity = StatusCode.OK.build();
        /*List<Shop> shops = excelService.getShopList();
        responseEntity.setData(shops);*/
        return responseEntity;
    }

}
